<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="../../../static/font-awesome-4.7.0/css/font-awesome.min.css" >
	<link rel="stylesheet" href="../../../static/vui/css/vui.css">

	<script type="text/javascript" src="../../../static/js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="../../../static/js/jquery.cookie.min.js"></script>
	<script type="text/javascript" src="../../../static/layer/layer.js"></script>
	<script type="text/javascript" src="../../../static/vui/js/vui.js"></script>
	<script type="text/javascript" src="../../../static/js/common.js"></script>
</head>
<body>

<div id="formArea">
	<div class="vui-from-table">

		<table>
			<tr>
				<td>
					<div class="vui-form-div">
						<label class="label required">员工姓名</label>
						<input type="text" class="input" name="name" placeholder="请输入员工姓名" autocomplete="off"/>
					</div>
				</td>
				<td rowspan="4">
					<div id="user_icon" style="background-color: #C4CCDF;cursor: pointer;margin: 0 auto;text-align: center;width: 200px;border-radius: 5px;position: relative;">
						<i style="font-size: 200px;color:#E4E9EF;" class="fa fa-user"></i>
					</div>
				</td>

			</tr>
			<tr>
				<td>
					<div class="vui-form-div">
						<label class="label required">登录账号</label>
						<input type="text" class="input" name="username" placeholder="全平台唯一帐号" autocomplete="off"/>
					</div>
				</td>
			</tr>
			<tr>

				<td>
					<div class="vui-form-div">
						<label class="label required">登录密码</label>
						<input type="text" class="input" placeholder="8-18位数字和字母的组合" name="password" autocomplete="off"/>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div class="vui-form-div">
						<label class="label required">所属公司</label>
						<div id="companyId"></div>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div class="vui-form-div">
						<label class="label">证件类型</label>
						<div id="cardTypeId"></div>
					</div>
				</td>
				<td>
					<div class="vui-form-div">
						<label class="label">证件号码</label>
						<input type="text" class="input" name="cardNo" maxlength="20" autocomplete="off"/>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div class="vui-form-div">
						<label class="label">手机号码</label>
						<input type="text" class="input" name="phone" maxlength="15" autocomplete="off"/>
					</div>
				</td>
			</tr>

			<tr>
				<td colspan="2">
					<div class="vui-form-div">
						<label class="label">员工备注</label>
						<input type="text" class="input" style="    width: 567px;" maxlength="20" name="comment" autocomplete="off"/>
					</div>
				</td>
			</tr>
		</table>

	</div>
</div>


<script>

$(function () {

    $('#cardTypeId').combobox({
        name:'cardTypeId',
        click:function(text,value){
            //alert(text+'-----------'+value);
        },
        data:[{text:'身份证',value:1},{text:'驾驶证',value:2},{text:'护照',value:3},{text:'军人证',value:4},{text:'港澳身份证',value:5},{text:'台胞证',value:6},{text:'其它',value:7}]
    });

    $('#companyId').search({
        name:'companyId',
        click:function(){
            var index = parent.layer.getFrameIndex(window.name);
            app.window(parent.layer,{
                title:'机构选择',
                btn:[],
                area: ['600px', '600px'],
                content: '../../common/company_tree.html?index='+index+'&searchId=companyId'
            });
        }
    });

    var company = {"companyId":app.getCompanyId(),"companyId_text":app.getCompanyName()};
    app.resetForm(company);

});

app.getOkBtn().click(function(){
	if( !checkForm() ){
		return;
	}

	var password = $.trim($('input[name="password"]').val());
	if( password.length < 8 || password.length> 18 ){
        app.msg(layer,'密码必须为8-18位数字和字母的组合',2);
        return;
    }

    var p1 = /[0-9]/,p2 = /[a-z]/i;
    if( !p1.test(password) || !p2.test(password) ){
        app.msg(layer,'密码必须为8-18位数字和字母的组合',2);
        return;
    }

	app.request({
		url:'user/insert',
		data:app.serializeForm(),
		success:app.actionSuccess_parent
	});
});

function checkForm(){

    var checkOptions = [
        {type:'input',name:'name',verify:[{type:'required'},{type:'length',value:5}]},
        {type:'input',name:'username',verify:[{type:'required'},{type:'length',value:20}]},
        {type:'input',name:'cardNo',verify:[{type:'length',value:18}]}
    ];

	return app.checkForm(checkOptions);
}

</script>

</body>
</html>